const fs = require('fs')
const promisify = require('util').promisify
//接收将普通方法包装为返回promise对象的方法

const readFile = promisify(fs.readFile)

async function p1 () {
    const data = readFile('./1.txt', 'utf8', (err, data ) => {
        if(err) {
            return (err)
        }else {
            return (data)
        }
    })   
    return data 

}
async function p2() {
    return  fs.readFile('./2.txt', 'utf8', (err, data) => {
        if(err) {
            return err
        }else {
            return data
        }
    })
}
async function p3() {
    return fs.readFile('./2.txt', 'utf8', (err, data) => {
        if(err) {
            return err
        }else {
            return data
        }
    })
}

async function readData() {
    try{

        const p1 = await readFile('./1.txt', 'utf8')   
        const p2 = await readFile('./2.txt', 'utf8')   
        const p3 = await readFile('./3.txt', 'utf8') 
        console.log(p1)
        console.log(p2)
        console.log(p3)
    } catch (err) {
        console.log(err)
    }

}
